/**
 * 
 */
package com.changil.nowonchangilchurch.protocol.dto;

import java.util.ArrayList;
import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author zeropol2
 *
 */
public class Article extends BeanBase{
	public int id;
	public int boardId;
	public String title;
	public String content;
	public User writer;
	public String writtenDateTime;
	public AttachmentImageList list = new AttachmentImageList();
	
	public Article() {
		
	}
	
	public Article(JSONObject rawData) {
		this();
		create(rawData);
	}
	
	@Override
	public void create(JSONObject data) {
		try{
			if ( !data.isNull("id")){
				id = data.getInt("id");				
			}
			
			if( !data.isNull("boardId")) {
				boardId = data.getInt("boardId");
			}
			
			if( !data.isNull("title")) {
				title = data.getString("title");
			}
			
			if( !data.isNull("content")) {
				content = data.getString("content");
			}
			
			if( !data.isNull("writer")) {
				writer = new User(data.getJSONObject("writer"));
			}
			
			if( !data.isNull("writtenDateTime")) {
				writtenDateTime = data.getString("writtenDateTime");
			}
			
			
			if ( !data.isNull("list")){
				list = new AttachmentImageList(data.getJSONObject("list"));
			}
		} catch(JSONException e) {
			handleException(e);
		}
	}
	
}
